Component({
    data: {
      selected: 0,
      color: "#666",
      selectedColor: "#ff9800",
      list: [
        {
          pagePath: "/pages/Home/Home",
          text: "首页",
          iconPath: "/assets/tabbar/home.jpg",
          selectedIconPath: "/assets/tabbar/home1.jpg"
        },
        {
            pagePath: "/pages/cart_index/cart_index",
            text: "商店",
            iconPath: "/assets/tabbar/store.png",
            selectedIconPath: "/assets/tabbar/store1.png"
        },
        {
            pagePath: "/pages/Sendpost/Sendpost",
            text: "发帖",
            iconPath: "/assets/tabbar/cat.png",
            selectedIconPath: "/assets/tabbar/cat1.png"
        },
        {
            pagePath: "/pages/messages/messages",
            text: "消息",
            iconPath: "/assets/tabbar/message.png",
            selectedIconPath: "/assets/tabbar/message1.png"
        },
        {
          pagePath: "/pages/person_all/person_all",
          text: "个人",
          iconPath: "/assets/tabbar/person.png",
          selectedIconPath: "/assets/tabbar/person1.png"
        }
        
      ]
    },
    methods: {
      switchTab(e) {
        const index = e.currentTarget.dataset.index;  // 获取当前点击的 tab index
            this.setData({
                selected: index  // 更新 selected 为点击的 tab index
            });
            wx.switchTab({
            url: this.data.list[index].pagePath  // 跳转到对应页面
            });
      }
    }
  });
  